package com.xing.config;

import com.xing.entity.MinioEntity;
import io.minio.MinioClient;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version 1.0
 * @Author Xing
 * @Date 2024/4/11 17:14
 */
@Configuration
@EnableConfigurationProperties(MinioEntity.class)
public class MinioConfiguration {

    @Autowired
    private MinioEntity entity;

    @Bean
    @SneakyThrows
    public MinioClient minioClient(){
        return MinioClient.builder()
                .endpoint(entity.getEndpoint())
                .credentials(entity.getAccessKey(),entity.getSecretKey())
                .build();
    }

}
